package uk.ac.lkl.common.allocator.event;



import uk.ac.lkl.common.util.EventSupport;
import uk.ac.lkl.lpp.dirtyListener;

// should be AllocatorListener<T> for EventSupport but can't do
// this due to erasure issues with getListenerClass.
public class AllocatorSupport<O> extends EventSupport<AllocatorListener> {

    public AllocatorSupport(Object source) {
        super(source);
    }


    protected Class<AllocatorListener> getListenerClass() {
        return AllocatorListener.class;
    }


    public void fireAllocationChanged(AllocatorEvent<O> e) {
        AllocatorListener<O>[] listeners = (AllocatorListener<O>[]) getListeners();
        for (int i = 0; i < listeners.length; i++)
            listeners[i].allocationChanged(e);
        dirtyListener.setDirty();
    }

}
